using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace PipeModifier
{
	/// <summary>
	/// Summary description for PipeProperties.
	/// </summary>
	public class PipeProperties : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid dataGrid1;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public PipeProperties(DataTable table)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			
			// do some magic here disable the Display name so we can't change the properties
			DataGridTableStyle dgStyle = new DataGridTableStyle();
			dgStyle.AllowSorting = false;
			dgStyle.MappingName = "Table1";
			DataGridTextBoxColumn key = new DataGridTextBoxColumn();
			key.MappingName = "Key";
			key.HeaderText = "Key";
			key.Width = 100;
			key.ReadOnly = true;
			dgStyle.GridColumnStyles.Add(key);
			// Add a second column style.
			DataGridColumnStyle Value = new DataGridTextBoxColumn();
			Value.MappingName = "Value";
			Value.HeaderText = "Value";
			Value.Width = 150;
			Value.ReadOnly = false;
			dgStyle.GridColumnStyles.Add(Value);
			dataGrid1.TableStyles.Add(dgStyle);

			// disallow new rows from being created
			dataGrid1.DataSource = table;
			CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
			((DataView)cm.List).AllowNew = false;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 0);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(302, 205);
			this.dataGrid1.TabIndex = 0;
			// 
			// PipeProperties
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(302, 205);
			this.Controls.Add(this.dataGrid1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "PipeProperties";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "PipeProperties";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		public DataTable GetTable
		{
			get
			{
				return (DataTable)dataGrid1.DataSource;
			}
		}
	}
}
